local skel=fk.CreateSkill{
    name = "steam__danggu",
    tags = { Skill.Compulsory },
  }

Fk:loadTranslationTable{
  ["steam__danggu"] = "党锢",
  [":steam__danggu"] = "锁定技，每持续两个中央区牌数为偶数的回合结束后，你摸一张牌并视为使用【铁索连环】。",
  ["@steam__danggu"] = "党锢",
}

--判断奇偶性并返回，奇数返回1，偶数返回0
local check_even=function(n)
  if n%2==0 then
    return "偶"
  else 
    return "奇"        
  end
end

--向列表中加一个数，若大于2，并移除第一个数
local add_and_remove=function(list,n)
  table.insert(list,n)
  if #list>2 then
    table.remove(list,1)
  end
end

skel:addEffect(fk.TurnEnd, {
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
      if not player:hasSkill(skel.name) then return end
      if not target==player then return end
      local room=player.room
      local n = math.min(#(Fk:currentRoom():getBanner("@$CenterArea") or {}),99)
      local x=check_even(n)
      local marks=player:getTableMark("@steam__danggu")
      add_and_remove(marks,x)
      room:setPlayerMark(player,"@steam__danggu",marks)
      if #marks==2 and table.every(marks,function(v) return v=="偶" end) then
        return true
      end
    end,
    on_use= function(self, event, target, player, data)
      local room=player.room
      player:drawCards(1)
      room:askToUseVirtualCard(player,{
        name = "iron_chain",
        skill_name = self.name,
      })
    end,
  })




skel:addAcquireEffect(function (self, player, is_start)
    local room = player.room
    room:addSkill("#CenterArea")
end)





return skel